<?php
/**
 * Created by PhpStorm.
 * User: wangchaozhen
 * Date: 2018/6/9
 * Time: 15:06
 */
namespace App\Http\Validate\Inquiry;
use Validator;


class store
{
    public static function validate($request)
    {
        $rules = [
            'goods_id' => 'required',
            'number' => 'required|Numeric|min:1',
        ];

        $message = [
            'goods_id.required' => '找不到此类商品',
            'number.required' => '数量不能为空',
        ];

        $validator = Validator::make($request->all(),$rules,$message);
        $errors = $validator->errors()->all();
        if($errors){
            throw new \Exception($errors[0]);
        }
    }
}